<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div class="box">盒子</div>
    <div class="box">盒子</div>
    <div id="nav">
        <ul>
            <li>首页</li>
            <li>产品</li>
        </ul>
    </div>
    <script>
        //1.getElementsByClassName 根据类名获取元素集合
        var boxes = document.getElementsByClassName('box');
        console.log(boxes);

        //2.querySelector 返回指定选择器的第一个元素对象
        var firstBox = document.querySelector('.box');
        console.log(firstBox);
        var nav = document.querySelector('#nav');
        console.log(nav);
        var li1 = document.querySelector('#nav ul li');
        console.log(li1);

        //3.querySelectAll 返回指定选择器的所有对象
        var allBox = document.querySelectorAll('box');
        console.log(allBox);

        //4.获取body
        var bd = document.body;
        console.log(bd);
        console.dir(bd);

        //获取html
        var hl = document.documentElement;
        console.log(hl);
    </script>
</body>

</html>